package com.dongdong.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.dongdong.mapper.TbSellerMapper;
import com.dongdong.pojo.TbSeller;
import com.dongdong.pojo.TbSellerExample;
import com.dongdong.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Service
@org.springframework.stereotype.Service
public class LoginServiceImpl implements LoginService {


    @Autowired
    private TbSellerMapper tbSellerMapper;

    @Override
    public boolean selectName(String lname) {
        TbSellerExample example = new TbSellerExample();
        TbSellerExample.Criteria criteria = example.createCriteria();
        criteria.andLnameEqualTo(lname);
        List<TbSeller> tbSellers = tbSellerMapper.selectByExample(example);
        if (tbSellers == null || tbSellers.size() <= 0){
            return true;
        }
        return false;
    }

    @Override
    public boolean insert(TbSeller tbSeller) {
        int i = tbSellerMapper.insertSelective(tbSeller);
        return i > 0;
    }


    @Override
    public TbSeller selectNa(String username) {
        TbSellerExample example = new TbSellerExample();
        TbSellerExample.Criteria criteria = example.createCriteria();
        criteria.andLnameEqualTo(username);
        List<TbSeller> tbSellers = tbSellerMapper.selectByExample(example);
        if (tbSellers == null || tbSellers.size() <= 0){
            return null;
        }
        return tbSellers.get(0);
    }
}
